﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NativeDataOperation.Business;
using NativeDataOperation.Interfaces;
using WebFoundation;
using WebFoundation.Data;

namespace DDHDeepTunnel.EquipmentManagement.Data
{
    public class SqlBatchWritingDAO<T> : WritableDAO<T> where T : class
    {
        public DbManager _dbManager;
        public IDbTransaction _transaction;

        public SqlBatchWritingDAO(DbManager dbManager, IDbTransaction transaction = null)
            : base(dbManager)
        {
            _dbManager = dbManager;
            _transaction = transaction;
        }

        #region •User-defined Attribute : NativeDataOperation.Interfaces.Attributes• && •DSS Web Foundation Server•

        /// <summary>
        /// default:insert batch •User-defined Attribute : NativeDataOperation.Interfaces.Attributes•
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entityList">IEnumerable<T></param>
        /// <returns>string:comments</returns>
        public string InsertBatch<T>(IEnumerable<T> entityList) where T : class
        {
            var dataBaseBatch = new DataBaseBatch();
            return dataBaseBatch.InsertBatch(entityList, this._dbManager, this._transaction);
        }

        ///// <summary>
        ///// default:insert batch •User-defined Attribute : NativeDataOperation.Interfaces.Attributes•
        ///// </summary>
        ///// <typeparam name="T"></typeparam>
        ///// <param name="entityList">IEnumerable<T></param>
        ///// <param name="selectColomnNameList">List<string>:selectColomnNameList</param>
        ///// <returns>string:comments</returns>
        //public string InsertBatchSelectColumns<T>(IEnumerable<T> entityList, List<string> selectColomnNameList) where T : class
        //{
        //    var sqlBatch = new DataBaseBatch();
        //    return sqlBatch.InsertBatchSelectColumns(entityList, selectColomnNameList, this._transaction, this._dbManager.Connection,
        //        this._dbManager.DBType);
        //}

        ///// <summary>
        ///// default:insert batch •DSS Web Foundation Server•
        ///// </summary>
        ///// <typeparam name="T"></typeparam>
        ///// <param name="entityList">IEnumerable<T></param>
        ///// <returns>string:comments</returns>
        //public string InsertBatchDwfs<T>(IEnumerable<T> entityList) where T : class
        //{
        //    var sqlBatch = new DataBaseBatch();
        //    return sqlBatch.InsertBatchDwfs(entityList, this._transaction, this._dbManager.Connection,
        //        this._dbManager.DBType);
        //}

        ///// <summary>
        ///// default:insert batch •DSS Web Foundation Server•
        ///// </summary>
        ///// <typeparam name="T"></typeparam>
        ///// <param name="entityList">IEnumerable<T></param>
        ///// <param name="selectColomnNameList">List<string>:selectColomnNameList</param>
        ///// <returns>string:comments</returns>
        //public string InsertBatchSelectColumnsDwfs<T>(IEnumerable<T> entityList, List<string> selectColomnNameList) where T : class
        //{
        //    var sqlBatch = new DataBaseBatch();
        //    return sqlBatch.InsertBatchSelectColumnsDwfs(entityList, selectColomnNameList, this._transaction, this._dbManager.Connection,
        //        this._dbManager.DBType);
        //}

        ///// <summary>
        ///// default:insert Bulk Copy //todo:Sqlserver complete;other db need to extend the finding
        ///// </summary>
        ///// <typeparam name="T"></typeparam>
        ///// <param name="entityList">IEnumerable<T></param>
        ///// <returns>string:comments</returns>
        //public string BatchSqlBulkCopy<T>(IEnumerable<T> entityList) where T : class
        //{
        //    var sqlBatch = new DataBaseBatch();
        //    return sqlBatch.BatchSqlBulkCopy(entityList, this._transaction, this._dbManager.Connection,
        //        this._dbManager.DBType);
        //}

        #endregion

        #region Update batch •User-defined Attribute : NativeDataOperation.Interfaces.Attributes• && •DSS Web Foundation Server•

        /// <summary>
        /// default:Update batch •User-defined Attribute : NativeDataOperation.Interfaces.Attributes•
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entityList">IEnumerable<T></param>
        /// <returns>string:comments</returns>
        public string UpdateBatch<T>(IEnumerable<T> entityList) where T : class
        {
            var dataBaseBatch = new DataBaseBatch();
            return dataBaseBatch.UpdateBatch(entityList, this._dbManager, this._transaction);
        }

        /////// <summary>
        /////// default:Update batch •User-defined Attribute : NativeDataOperation.Interfaces.Attributes•
        /////// </summary>
        /////// <typeparam name="T"></typeparam>
        /////// <param name="entityList">IEnumerable<T></param>
        /////// <param name="selectUpdateColomnNameList">List<string>:selectUpdateColomnNameList</param>
        /////// <param name="selectWhereColomnNameList">List<string>:selectWhereColomnNameList</param>
        /////// <returns>string:comments</returns>
        ////public string UpdateBatchSelectColumns<T>(IEnumerable<T> entityList, List<string> selectUpdateColomnNameList, List<string> selectWhereColomnNameList) where T : class
        ////{
        ////    var sqlBatch = new SqlBatch();
        ////    return sqlBatch.UpdateBatchSelectColumns(entityList, selectUpdateColomnNameList, selectWhereColomnNameList, this._transaction, this._dbManager.Connection,
        ////        this._dbManager.DBType);
        ////}

        /////// <summary>
        /////// default:Update batch •DSS Web Foundation Server•
        /////// </summary>
        /////// <typeparam name="T"></typeparam>
        /////// <param name="entityList">IEnumerable<T></param>
        /////// <returns>string:comments</returns>
        ////public string UpdateBatchDwfs<T>(IEnumerable<T> entityList) where T : class
        ////{
        ////    var sqlBatch = new SqlBatch();
        ////    return sqlBatch.UpdateBatchDwfs(entityList, this._transaction, this._dbManager.Connection,
        ////        this._dbManager.DBType);
        ////}

        /////// <summary>
        /////// default:Update batch •DSS Web Foundation Server•
        /////// </summary>
        /////// <typeparam name="T"></typeparam>
        /////// <param name="entityList">IEnumerable<T></param>
        /////// <param name="selectUpdateColomnNameList">List<string>:selectUpdateColomnNameList</param>
        /////// <param name="selectWhereColomnNameList">List<string>:selectWhereColomnNameList</param>
        /////// <returns>string:comments</returns>
        ////public string UpdateBatchSelectColumnsDwfs<T>(IEnumerable<T> entityList, List<string> selectUpdateColomnNameList, List<string> selectWhereColomnNameList) where T : class
        ////{
        ////    var sqlBatch = new SqlBatch();
        ////    return sqlBatch.UpdateBatchSelectColumnsDwfs(entityList, selectUpdateColomnNameList, selectWhereColomnNameList, this._transaction, this._dbManager.Connection,
        ////        this._dbManager.DBType);
        ////}

        #endregion
    }
}
